import ftp from 'vinyl-ftp'

/**
 * FTP代码自动化发布
 *
 * vsftp：gulp-vsftp  https://www.npmjs.com/package/gulp-vsftp
 * ftp:   vinyl-ftp   https://www.npmjs.com/package/vinyl-ftp
 */
module.exports = (gulp, $, config) => {
    return () => {
        const conn = ftp.create({
	        host    : '114.55.42.11',
	        user    : 'ftpuser',
	        password: 'Ftp8888//**--',
	        parallel: 10,
	        log     : $.util.log
	    });

	    return gulp.src(config.ftp.src, { buffer: false } )
				.pipe(conn.newer(config.ftp.dest))
				.pipe(conn.dest(config.ftp.dest));
    }
}